{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "provenance": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "3xW4O0zuKfWD"
      },
      "outputs": [],
      "source": [
        "import os\n",
        "from openai import OpenAI\n",
        "import rich\n",
        "from google.colab import userdata"
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "api_key = userdata.get('OPENAI_API_KEY')\n",
        "MODEL = \"gpt-4o-mini\"\n",
        "\n",
        "openai = OpenAI(api_key=api_key)"
      ],
      "metadata": {
        "id": "vUydnLeLKs03"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "Search the web for the latest information before generating a response\n",
        "\n",
        "1) In Chat API, model always retrieves information from web before responding to your query\n",
        "\n",
        "2) In Responses API, you enable web search by configuring it in the tools, and model can choose to serach the web or not based on the content of the input prompt."
      ],
      "metadata": {
        "id": "blCx6gu1Vl46"
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "In this example, the prompt for both the Chat API and the Responses API is a general question that the model can answer directly. However, in the case of the Chat API's `gpt-4o-search-preview` model, it will always perform a web search."
      ],
      "metadata": {
        "id": "wSqr0gLd4CmV"
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "# Chat Completion API\n",
        "\n",
        "https://platform.openai.com/docs/guides/tools-web-search?api-mode=chat"
      ],
      "metadata": {
        "id": "5wlqKfVBKyjD"
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "Always search the web first"
      ],
      "metadata": {
        "id": "79PCOO9i3Yel"
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "Note: The annotation object will contain links to the web pages from which the model extracted information to construct the output\n",
        "```\n",
        "{\n",
        "    type:'url_citation',\n",
        "    url_citation : {\n",
        "        end_index: 0,\n",
        "        start_index: 0,\n",
        "        title:\"title\",\n",
        "        url:'url'\n",
        "    }\n",
        "}\n",
        "```"
      ],
      "metadata": {
        "id": "GYwnPiN5b8gf"
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "In Chat API we have to use specific model that is fine tuned for web searches `gpt-4o-search-preview`"
      ],
      "metadata": {
        "id": "bRPvp6qR3e9z"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# Only Prompt is different\n",
        "response = openai.chat.completions.create(\n",
        "    model=\"gpt-4o-search-preview\",\n",
        "    web_search_options={},\n",
        "    messages=[\n",
        "        {\n",
        "            \"role\": \"user\",\n",
        "            # As we are using the search preview model, even for this question it will search the web\n",
        "            \"content\": \"What is Agentic AI?\",\n",
        "        }\n",
        "    ],\n",
        ")\n",
        "\n",
        "print(response.choices[0].message.content)\n",
        "# rich.print(response)\n",
        "print(len(response.choices[0].message.annotations))\n",
        "rich.print(response.choices[0].message.annotations)"
      ],
      "metadata": {
        "id": "dBrUkMCUKz0s",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        },
        "outputId": "6c5d9ba6-5fc0-45c4-d3c3-dbf58bda8ea5"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Agentic AI refers to artificial intelligence systems capable of autonomously executing tasks, making decisions, and adapting to changing conditions with minimal human intervention. Unlike traditional AI, which typically follows predefined instructions and requires human oversight, agentic AI systems exhibit a higher degree of independence and adaptability.\n",
            "\n",
            "**Key Characteristics of Agentic AI:**\n",
            "\n",
            "- **Autonomy:** These systems can initiate actions and set goals independently, reducing the need for constant human input. ([innodata.com](https://innodata.com/what-is-agentic-ai/?utm_source=openai))\n",
            "\n",
            "- **Contextual Understanding:** With advanced natural language processing capabilities, agentic AI can comprehend complex instructions and scenarios, enabling nuanced decision-making. ([innodata.com](https://innodata.com/what-is-agentic-ai/?utm_source=openai))\n",
            "\n",
            "- **Dynamic Planning:** Agentic AI can adjust its strategies based on real-time data and changing circumstances, ensuring effective responses to new information. ([innodata.com](https://innodata.com/what-is-agentic-ai/?utm_source=openai))\n",
            "\n",
            "- **Adaptive Execution:** These systems can seamlessly transition between different tasks and applications, optimizing workflow efficiency. ([innodata.com](https://innodata.com/what-is-agentic-ai/?utm_source=openai))\n",
            "\n",
            "- **Collaborative Interaction:** Agentic AI is designed to interact and collaborate with other systems and humans, facilitating integrated operations across various platforms. ([innodata.com](https://innodata.com/what-is-agentic-ai/?utm_source=openai))\n",
            "\n",
            "**Agentic AI Workflow:**\n",
            "\n",
            "1. **Perception:** Collecting information from the environment using tools like cameras, microphones, APIs, or data feeds.\n",
            "\n",
            "2. **Reasoning (Analysis):** Processing the gathered data to understand the situation, using models for vision or natural language to interpret inputs.\n",
            "\n",
            "3. **Decision-Making and Action:** Determining the appropriate action based on the analysis and executing it, such as sending commands to a robot or making an API call.\n",
            "\n",
            "4. **Learning:** Evaluating the outcomes of actions taken and using the results to guide future decisions, continuously improving performance over time. ([reliasoftware.com](https://reliasoftware.com/blog/what-is-agentic-ai?utm_source=openai))\n",
            "\n",
            "**Applications of Agentic AI:**\n",
            "\n",
            "- **Information Technology (IT):** Automating routine service desk requests and technical support tasks, allowing professionals to focus on more complex issues. ([innodata.com](https://innodata.com/what-is-agentic-ai/?utm_source=openai))\n",
            "\n",
            "- **Finance and Banking:** Monitoring transactions for fraudulent activity, providing real-time alerts, and reducing operational risks. ([innodata.com](https://innodata.com/what-is-agentic-ai/?utm_source=openai))\n",
            "\n",
            "- **Healthcare:** Assisting in diagnosing and treating patients, improving patient outcomes, and reducing healthcare costs. ([innodata.com](https://innodata.com/what-is-agentic-ai/?utm_source=openai))\n",
            "\n",
            "- **Retail:** Enhancing customer experiences and optimizing inventory management by analyzing customer preferences and adjusting inventory levels based on real-time sales data. ([innodata.com](https://innodata.com/what-is-agentic-ai/?utm_source=openai))\n",
            "\n",
            "- **Customer Service:** Serving as conversational assistants to improve response times and customer satisfaction by handling routine inquiries and escalating complex issues to human agents. ([innodata.com](https://innodata.com/what-is-agentic-ai/?utm_source=openai))\n",
            "\n",
            "**Distinction from Traditional AI:**\n",
            "\n",
            "Traditional AI systems are often limited to automating specific, predefined tasks and require human intervention for decision-making. In contrast, agentic AI systems are built to handle more intricate and dynamic tasks, leveraging advanced language models, scalable computing power, and integration capabilities to operate autonomously and adaptively. ([innodata.com](https://innodata.com/what-is-agentic-ai/?utm_source=openai))\n",
            "\n",
            "In summary, agentic AI represents a significant advancement in artificial intelligence, offering systems that can independently perceive, reason, decide, and learn, thereby enhancing efficiency and adaptability across various industries. \n",
            "12\n"
          ]
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "\u001b[1m[\u001b[0m\n",
              "    \u001b[1;35mAnnotation\u001b[0m\u001b[1m(\u001b[0m\n",
              "        \u001b[33mtype\u001b[0m=\u001b[32m'url_citation'\u001b[0m,\n",
              "        \u001b[33murl_citation\u001b[0m=\u001b[1;35mAnnotationURLCitation\u001b[0m\u001b[1m(\u001b[0m\n",
              "            \u001b[33mend_index\u001b[0m=\u001b[1;36m600\u001b[0m,\n",
              "            \u001b[33mstart_index\u001b[0m=\u001b[1;36m524\u001b[0m,\n",
              "            \u001b[33mtitle\u001b[0m=\u001b[32m'What is Agentic AI? — Innodata'\u001b[0m,\n",
              "            \u001b[33murl\u001b[0m=\u001b[32m'https://innodata.com/what-is-agentic-ai/?\u001b[0m\u001b[32mutm_source\u001b[0m\u001b[32m=\u001b[0m\u001b[32mopenai\u001b[0m\u001b[32m'\u001b[0m\n",
              "        \u001b[1m)\u001b[0m\n",
              "    \u001b[1m)\u001b[0m,\n",
              "    \u001b[1;35mAnnotation\u001b[0m\u001b[1m(\u001b[0m\n",
              "        \u001b[33mtype\u001b[0m=\u001b[32m'url_citation'\u001b[0m,\n",
              "        \u001b[33murl_citation\u001b[0m=\u001b[1;35mAnnotationURLCitation\u001b[0m\u001b[1m(\u001b[0m\n",
              "            \u001b[33mend_index\u001b[0m=\u001b[1;36m862\u001b[0m,\n",
              "            \u001b[33mstart_index\u001b[0m=\u001b[1;36m786\u001b[0m,\n",
              "            \u001b[33mtitle\u001b[0m=\u001b[32m'What is Agentic AI? — Innodata'\u001b[0m,\n",
              "            \u001b[33murl\u001b[0m=\u001b[32m'https://innodata.com/what-is-agentic-ai/?\u001b[0m\u001b[32mutm_source\u001b[0m\u001b[32m=\u001b[0m\u001b[32mopenai\u001b[0m\u001b[32m'\u001b[0m\n",
              "        \u001b[1m)\u001b[0m\n",
              "    \u001b[1m)\u001b[0m,\n",
              "    \u001b[1;35mAnnotation\u001b[0m\u001b[1m(\u001b[0m\n",
              "        \u001b[33mtype\u001b[0m=\u001b[32m'url_citation'\u001b[0m,\n",
              "        \u001b[33murl_citation\u001b[0m=\u001b[1;35mAnnotationURLCitation\u001b[0m\u001b[1m(\u001b[0m\n",
              "            \u001b[33mend_index\u001b[0m=\u001b[1;36m1102\u001b[0m,\n",
              "            \u001b[33mstart_index\u001b[0m=\u001b[1;36m1026\u001b[0m,\n",
              "            \u001b[33mtitle\u001b[0m=\u001b[32m'What is Agentic AI? — Innodata'\u001b[0m,\n",
              "            \u001b[33murl\u001b[0m=\u001b[32m'https://innodata.com/what-is-agentic-ai/?\u001b[0m\u001b[32mutm_source\u001b[0m\u001b[32m=\u001b[0m\u001b[32mopenai\u001b[0m\u001b[32m'\u001b[0m\n",
              "        \u001b[1m)\u001b[0m\n",
              "    \u001b[1m)\u001b[0m,\n",
              "    \u001b[1;35mAnnotation\u001b[0m\u001b[1m(\u001b[0m\n",
              "        \u001b[33mtype\u001b[0m=\u001b[32m'url_citation'\u001b[0m,\n",
              "        \u001b[33murl_citation\u001b[0m=\u001b[1;35mAnnotationURLCitation\u001b[0m\u001b[1m(\u001b[0m\n",
              "            \u001b[33mend_index\u001b[0m=\u001b[1;36m1320\u001b[0m,\n",
              "            \u001b[33mstart_index\u001b[0m=\u001b[1;36m1244\u001b[0m,\n",
              "            \u001b[33mtitle\u001b[0m=\u001b[32m'What is Agentic AI? — Innodata'\u001b[0m,\n",
              "            \u001b[33murl\u001b[0m=\u001b[32m'https://innodata.com/what-is-agentic-ai/?\u001b[0m\u001b[32mutm_source\u001b[0m\u001b[32m=\u001b[0m\u001b[32mopenai\u001b[0m\u001b[32m'\u001b[0m\n",
              "        \u001b[1m)\u001b[0m\n",
              "    \u001b[1m)\u001b[0m,\n",
              "    \u001b[1;35mAnnotation\u001b[0m\u001b[1m(\u001b[0m\n",
              "        \u001b[33mtype\u001b[0m=\u001b[32m'url_citation'\u001b[0m,\n",
              "        \u001b[33murl_citation\u001b[0m=\u001b[1;35mAnnotationURLCitation\u001b[0m\u001b[1m(\u001b[0m\n",
              "            \u001b[33mend_index\u001b[0m=\u001b[1;36m1574\u001b[0m,\n",
              "            \u001b[33mstart_index\u001b[0m=\u001b[1;36m1498\u001b[0m,\n",
              "            \u001b[33mtitle\u001b[0m=\u001b[32m'What is Agentic AI? — Innodata'\u001b[0m,\n",
              "            \u001b[33murl\u001b[0m=\u001b[32m'https://innodata.com/what-is-agentic-ai/?\u001b[0m\u001b[32mutm_source\u001b[0m\u001b[32m=\u001b[0m\u001b[32mopenai\u001b[0m\u001b[32m'\u001b[0m\n",
              "        \u001b[1m)\u001b[0m\n",
              "    \u001b[1m)\u001b[0m,\n",
              "    \u001b[1;35mAnnotation\u001b[0m\u001b[1m(\u001b[0m\n",
              "        \u001b[33mtype\u001b[0m=\u001b[32m'url_citation'\u001b[0m,\n",
              "        \u001b[33murl_citation\u001b[0m=\u001b[1;35mAnnotationURLCitation\u001b[0m\u001b[1m(\u001b[0m\n",
              "            \u001b[33mend_index\u001b[0m=\u001b[1;36m2292\u001b[0m,\n",
              "            \u001b[33mstart_index\u001b[0m=\u001b[1;36m2202\u001b[0m,\n",
              "            \u001b[33mtitle\u001b[0m=\u001b[32m'What is Agentic AI? Workflows, Use Cases, Benefits & More | Relia Software'\u001b[0m,\n",
              "            \u001b[33murl\u001b[0m=\u001b[32m'https://reliasoftware.com/blog/what-is-agentic-ai?\u001b[0m\u001b[32mutm_source\u001b[0m\u001b[32m=\u001b[0m\u001b[32mopenai\u001b[0m\u001b[32m'\u001b[0m\n",
              "        \u001b[1m)\u001b[0m\n",
              "    \u001b[1m)\u001b[0m,\n",
              "    \u001b[1;35mAnnotation\u001b[0m\u001b[1m(\u001b[0m\n",
              "        \u001b[33mtype\u001b[0m=\u001b[32m'url_citation'\u001b[0m,\n",
              "        \u001b[33murl_citation\u001b[0m=\u001b[1;35mAnnotationURLCitation\u001b[0m\u001b[1m(\u001b[0m\n",
              "            \u001b[33mend_index\u001b[0m=\u001b[1;36m2564\u001b[0m,\n",
              "            \u001b[33mstart_index\u001b[0m=\u001b[1;36m2488\u001b[0m,\n",
              "            \u001b[33mtitle\u001b[0m=\u001b[32m'What is Agentic AI? — Innodata'\u001b[0m,\n",
              "            \u001b[33murl\u001b[0m=\u001b[32m'https://innodata.com/what-is-agentic-ai/?\u001b[0m\u001b[32mutm_source\u001b[0m\u001b[32m=\u001b[0m\u001b[32mopenai\u001b[0m\u001b[32m'\u001b[0m\n",
              "        \u001b[1m)\u001b[0m\n",
              "    \u001b[1m)\u001b[0m,\n",
              "    \u001b[1;35mAnnotation\u001b[0m\u001b[1m(\u001b[0m\n",
              "        \u001b[33mtype\u001b[0m=\u001b[32m'url_citation'\u001b[0m,\n",
              "        \u001b[33murl_citation\u001b[0m=\u001b[1;35mAnnotationURLCitation\u001b[0m\u001b[1m(\u001b[0m\n",
              "            \u001b[33mend_index\u001b[0m=\u001b[1;36m2778\u001b[0m,\n",
              "            \u001b[33mstart_index\u001b[0m=\u001b[1;36m2702\u001b[0m,\n",
              "            \u001b[33mtitle\u001b[0m=\u001b[32m'What is Agentic AI? — Innodata'\u001b[0m,\n",
              "            \u001b[33murl\u001b[0m=\u001b[32m'https://innodata.com/what-is-agentic-ai/?\u001b[0m\u001b[32mutm_source\u001b[0m\u001b[32m=\u001b[0m\u001b[32mopenai\u001b[0m\u001b[32m'\u001b[0m\n",
              "        \u001b[1m)\u001b[0m\n",
              "    \u001b[1m)\u001b[0m,\n",
              "    \u001b[1;35mAnnotation\u001b[0m\u001b[1m(\u001b[0m\n",
              "        \u001b[33mtype\u001b[0m=\u001b[32m'url_citation'\u001b[0m,\n",
              "        \u001b[33murl_citation\u001b[0m=\u001b[1;35mAnnotationURLCitation\u001b[0m\u001b[1m(\u001b[0m\n",
              "            \u001b[33mend_index\u001b[0m=\u001b[1;36m2980\u001b[0m,\n",
              "            \u001b[33mstart_index\u001b[0m=\u001b[1;36m2904\u001b[0m,\n",
              "            \u001b[33mtitle\u001b[0m=\u001b[32m'What is Agentic AI? — Innodata'\u001b[0m,\n",
              "            \u001b[33murl\u001b[0m=\u001b[32m'https://innodata.com/what-is-agentic-ai/?\u001b[0m\u001b[32mutm_source\u001b[0m\u001b[32m=\u001b[0m\u001b[32mopenai\u001b[0m\u001b[32m'\u001b[0m\n",
              "        \u001b[1m)\u001b[0m\n",
              "    \u001b[1m)\u001b[0m,\n",
              "    \u001b[1;35mAnnotation\u001b[0m\u001b[1m(\u001b[0m\n",
              "        \u001b[33mtype\u001b[0m=\u001b[32m'url_citation'\u001b[0m,\n",
              "        \u001b[33murl_citation\u001b[0m=\u001b[1;35mAnnotationURLCitation\u001b[0m\u001b[1m(\u001b[0m\n",
              "            \u001b[33mend_index\u001b[0m=\u001b[1;36m3235\u001b[0m,\n",
              "            \u001b[33mstart_index\u001b[0m=\u001b[1;36m3159\u001b[0m,\n",
              "            \u001b[33mtitle\u001b[0m=\u001b[32m'What is Agentic AI? — Innodata'\u001b[0m,\n",
              "            \u001b[33murl\u001b[0m=\u001b[32m'https://innodata.com/what-is-agentic-ai/?\u001b[0m\u001b[32mutm_source\u001b[0m\u001b[32m=\u001b[0m\u001b[32mopenai\u001b[0m\u001b[32m'\u001b[0m\n",
              "        \u001b[1m)\u001b[0m\n",
              "    \u001b[1m)\u001b[0m,\n",
              "    \u001b[1;35mAnnotation\u001b[0m\u001b[1m(\u001b[0m\n",
              "        \u001b[33mtype\u001b[0m=\u001b[32m'url_citation'\u001b[0m,\n",
              "        \u001b[33murl_citation\u001b[0m=\u001b[1;35mAnnotationURLCitation\u001b[0m\u001b[1m(\u001b[0m\n",
              "            \u001b[33mend_index\u001b[0m=\u001b[1;36m3503\u001b[0m,\n",
              "            \u001b[33mstart_index\u001b[0m=\u001b[1;36m3427\u001b[0m,\n",
              "            \u001b[33mtitle\u001b[0m=\u001b[32m'What is Agentic AI? — Innodata'\u001b[0m,\n",
              "            \u001b[33murl\u001b[0m=\u001b[32m'https://innodata.com/what-is-agentic-ai/?\u001b[0m\u001b[32mutm_source\u001b[0m\u001b[32m=\u001b[0m\u001b[32mopenai\u001b[0m\u001b[32m'\u001b[0m\n",
              "        \u001b[1m)\u001b[0m\n",
              "    \u001b[1m)\u001b[0m,\n",
              "    \u001b[1;35mAnnotation\u001b[0m\u001b[1m(\u001b[0m\n",
              "        \u001b[33mtype\u001b[0m=\u001b[32m'url_citation'\u001b[0m,\n",
              "        \u001b[33murl_citation\u001b[0m=\u001b[1;35mAnnotationURLCitation\u001b[0m\u001b[1m(\u001b[0m\n",
              "            \u001b[33mend_index\u001b[0m=\u001b[1;36m3971\u001b[0m,\n",
              "            \u001b[33mstart_index\u001b[0m=\u001b[1;36m3895\u001b[0m,\n",
              "            \u001b[33mtitle\u001b[0m=\u001b[32m'What is Agentic AI? — Innodata'\u001b[0m,\n",
              "            \u001b[33murl\u001b[0m=\u001b[32m'https://innodata.com/what-is-agentic-ai/?\u001b[0m\u001b[32mutm_source\u001b[0m\u001b[32m=\u001b[0m\u001b[32mopenai\u001b[0m\u001b[32m'\u001b[0m\n",
              "        \u001b[1m)\u001b[0m\n",
              "    \u001b[1m)\u001b[0m\n",
              "\u001b[1m]\u001b[0m\n"
            ],
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">[</span>\n",
              "    <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Annotation</span><span style=\"font-weight: bold\">(</span>\n",
              "        <span style=\"color: #808000; text-decoration-color: #808000\">type</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'url_citation'</span>,\n",
              "        <span style=\"color: #808000; text-decoration-color: #808000\">url_citation</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">AnnotationURLCitation</span><span style=\"font-weight: bold\">(</span>\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">end_index</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">600</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">start_index</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">524</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">title</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'What is Agentic AI? — Innodata'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">url</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'https://innodata.com/what-is-agentic-ai/?utm_source=openai'</span>\n",
              "        <span style=\"font-weight: bold\">)</span>\n",
              "    <span style=\"font-weight: bold\">)</span>,\n",
              "    <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Annotation</span><span style=\"font-weight: bold\">(</span>\n",
              "        <span style=\"color: #808000; text-decoration-color: #808000\">type</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'url_citation'</span>,\n",
              "        <span style=\"color: #808000; text-decoration-color: #808000\">url_citation</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">AnnotationURLCitation</span><span style=\"font-weight: bold\">(</span>\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">end_index</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">862</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">start_index</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">786</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">title</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'What is Agentic AI? — Innodata'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">url</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'https://innodata.com/what-is-agentic-ai/?utm_source=openai'</span>\n",
              "        <span style=\"font-weight: bold\">)</span>\n",
              "    <span style=\"font-weight: bold\">)</span>,\n",
              "    <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Annotation</span><span style=\"font-weight: bold\">(</span>\n",
              "        <span style=\"color: #808000; text-decoration-color: #808000\">type</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'url_citation'</span>,\n",
              "        <span style=\"color: #808000; text-decoration-color: #808000\">url_citation</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">AnnotationURLCitation</span><span style=\"font-weight: bold\">(</span>\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">end_index</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1102</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">start_index</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1026</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">title</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'What is Agentic AI? — Innodata'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">url</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'https://innodata.com/what-is-agentic-ai/?utm_source=openai'</span>\n",
              "        <span style=\"font-weight: bold\">)</span>\n",
              "    <span style=\"font-weight: bold\">)</span>,\n",
              "    <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Annotation</span><span style=\"font-weight: bold\">(</span>\n",
              "        <span style=\"color: #808000; text-decoration-color: #808000\">type</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'url_citation'</span>,\n",
              "        <span style=\"color: #808000; text-decoration-color: #808000\">url_citation</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">AnnotationURLCitation</span><span style=\"font-weight: bold\">(</span>\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">end_index</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1320</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">start_index</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1244</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">title</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'What is Agentic AI? — Innodata'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">url</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'https://innodata.com/what-is-agentic-ai/?utm_source=openai'</span>\n",
              "        <span style=\"font-weight: bold\">)</span>\n",
              "    <span style=\"font-weight: bold\">)</span>,\n",
              "    <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Annotation</span><span style=\"font-weight: bold\">(</span>\n",
              "        <span style=\"color: #808000; text-decoration-color: #808000\">type</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'url_citation'</span>,\n",
              "        <span style=\"color: #808000; text-decoration-color: #808000\">url_citation</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">AnnotationURLCitation</span><span style=\"font-weight: bold\">(</span>\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">end_index</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1574</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">start_index</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">1498</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">title</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'What is Agentic AI? — Innodata'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">url</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'https://innodata.com/what-is-agentic-ai/?utm_source=openai'</span>\n",
              "        <span style=\"font-weight: bold\">)</span>\n",
              "    <span style=\"font-weight: bold\">)</span>,\n",
              "    <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Annotation</span><span style=\"font-weight: bold\">(</span>\n",
              "        <span style=\"color: #808000; text-decoration-color: #808000\">type</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'url_citation'</span>,\n",
              "        <span style=\"color: #808000; text-decoration-color: #808000\">url_citation</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">AnnotationURLCitation</span><span style=\"font-weight: bold\">(</span>\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">end_index</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2292</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">start_index</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2202</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">title</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'What is Agentic AI? Workflows, Use Cases, Benefits &amp; More | Relia Software'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">url</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'https://reliasoftware.com/blog/what-is-agentic-ai?utm_source=openai'</span>\n",
              "        <span style=\"font-weight: bold\">)</span>\n",
              "    <span style=\"font-weight: bold\">)</span>,\n",
              "    <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Annotation</span><span style=\"font-weight: bold\">(</span>\n",
              "        <span style=\"color: #808000; text-decoration-color: #808000\">type</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'url_citation'</span>,\n",
              "        <span style=\"color: #808000; text-decoration-color: #808000\">url_citation</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">AnnotationURLCitation</span><span style=\"font-weight: bold\">(</span>\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">end_index</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2564</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">start_index</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2488</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">title</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'What is Agentic AI? — Innodata'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">url</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'https://innodata.com/what-is-agentic-ai/?utm_source=openai'</span>\n",
              "        <span style=\"font-weight: bold\">)</span>\n",
              "    <span style=\"font-weight: bold\">)</span>,\n",
              "    <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Annotation</span><span style=\"font-weight: bold\">(</span>\n",
              "        <span style=\"color: #808000; text-decoration-color: #808000\">type</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'url_citation'</span>,\n",
              "        <span style=\"color: #808000; text-decoration-color: #808000\">url_citation</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">AnnotationURLCitation</span><span style=\"font-weight: bold\">(</span>\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">end_index</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2778</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">start_index</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2702</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">title</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'What is Agentic AI? — Innodata'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">url</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'https://innodata.com/what-is-agentic-ai/?utm_source=openai'</span>\n",
              "        <span style=\"font-weight: bold\">)</span>\n",
              "    <span style=\"font-weight: bold\">)</span>,\n",
              "    <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Annotation</span><span style=\"font-weight: bold\">(</span>\n",
              "        <span style=\"color: #808000; text-decoration-color: #808000\">type</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'url_citation'</span>,\n",
              "        <span style=\"color: #808000; text-decoration-color: #808000\">url_citation</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">AnnotationURLCitation</span><span style=\"font-weight: bold\">(</span>\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">end_index</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2980</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">start_index</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2904</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">title</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'What is Agentic AI? — Innodata'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">url</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'https://innodata.com/what-is-agentic-ai/?utm_source=openai'</span>\n",
              "        <span style=\"font-weight: bold\">)</span>\n",
              "    <span style=\"font-weight: bold\">)</span>,\n",
              "    <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Annotation</span><span style=\"font-weight: bold\">(</span>\n",
              "        <span style=\"color: #808000; text-decoration-color: #808000\">type</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'url_citation'</span>,\n",
              "        <span style=\"color: #808000; text-decoration-color: #808000\">url_citation</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">AnnotationURLCitation</span><span style=\"font-weight: bold\">(</span>\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">end_index</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">3235</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">start_index</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">3159</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">title</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'What is Agentic AI? — Innodata'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">url</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'https://innodata.com/what-is-agentic-ai/?utm_source=openai'</span>\n",
              "        <span style=\"font-weight: bold\">)</span>\n",
              "    <span style=\"font-weight: bold\">)</span>,\n",
              "    <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Annotation</span><span style=\"font-weight: bold\">(</span>\n",
              "        <span style=\"color: #808000; text-decoration-color: #808000\">type</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'url_citation'</span>,\n",
              "        <span style=\"color: #808000; text-decoration-color: #808000\">url_citation</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">AnnotationURLCitation</span><span style=\"font-weight: bold\">(</span>\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">end_index</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">3503</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">start_index</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">3427</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">title</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'What is Agentic AI? — Innodata'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">url</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'https://innodata.com/what-is-agentic-ai/?utm_source=openai'</span>\n",
              "        <span style=\"font-weight: bold\">)</span>\n",
              "    <span style=\"font-weight: bold\">)</span>,\n",
              "    <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Annotation</span><span style=\"font-weight: bold\">(</span>\n",
              "        <span style=\"color: #808000; text-decoration-color: #808000\">type</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'url_citation'</span>,\n",
              "        <span style=\"color: #808000; text-decoration-color: #808000\">url_citation</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">AnnotationURLCitation</span><span style=\"font-weight: bold\">(</span>\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">end_index</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">3971</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">start_index</span>=<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">3895</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">title</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'What is Agentic AI? — Innodata'</span>,\n",
              "            <span style=\"color: #808000; text-decoration-color: #808000\">url</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'https://innodata.com/what-is-agentic-ai/?utm_source=openai'</span>\n",
              "        <span style=\"font-weight: bold\">)</span>\n",
              "    <span style=\"font-weight: bold\">)</span>\n",
              "<span style=\"font-weight: bold\">]</span>\n",
              "</pre>\n"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "# Responses API\n",
        "\n",
        "https://platform.openai.com/docs/guides/tools-web-search?api-mode=responses"
      ],
      "metadata": {
        "id": "tCzSosP5K-JR"
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "Model will choose to search the web or not based on the content of the input prompt."
      ],
      "metadata": {
        "id": "zEHOqHav3tTm"
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "Note: The annotation object will contain links to the web pages from which the model extracted information to construct the output.\n",
        "\n",
        "In the Responses API, you can see that the annotation object does not contain a nested `url_citation` object, unlike in the Chat API.\n",
        "```\n",
        "{\n",
        "    type:'url_citation',\n",
        "    end_index: 0,\n",
        "    start_index: 0,\n",
        "    title:\"title\",\n",
        "    url:'url'\n",
        "}\n",
        "```"
      ],
      "metadata": {
        "id": "9RzqTpyW3vL1"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# Only Prompt is different\n",
        "response = openai.responses.create(\n",
        "    model=MODEL,  # using standard model\n",
        "    tools=[{\"type\": \"web_search_preview\"}],\n",
        "    # As we are using the web search preview as tool, model will decide to use the web search or not\n",
        "    input=\"What is Agentic AI?\"\n",
        ")\n",
        "\n",
        "print(response.output_text)\n",
        "rich.print(response.output)\n",
        "rich.print(response.tools)\n",
        "# rich.print(response)"
      ],
      "metadata": {
        "id": "gUjC_PQCcETm",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 672
        },
        "outputId": "56626548-0e51-404e-c53a-afdad12d8300"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Agentic AI refers to artificial intelligence systems that possess a degree of autonomy or agency, allowing them to make decisions and take actions in dynamic environments without constant human oversight. This type of AI is characterized by its ability to:\n",
            "\n",
            "1. **Interpret Context**: Understand and analyze situational contexts to make informed decisions.\n",
            "2. **Learn from Experience**: Adapt and improve performance over time through machine learning techniques.\n",
            "3. **Act Independently**: Carry out tasks or goals without needing specific instructions for every action.\n",
            "4. **Exhibit Goal-Directed Behavior**: Operate with specific objectives in mind, often prioritizing efficiency and effectiveness.\n",
            "\n",
            "Applications of Agentic AI can be found across various domains, such as autonomous vehicles, robotics, and sophisticated virtual assistants. However, its development raises important ethical and safety considerations, including accountability, transparency, and potential unintended consequences.\n"
          ]
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "\u001b[1m[\u001b[0m\n",
              "    \u001b[1;35mResponseOutputMessage\u001b[0m\u001b[1m(\u001b[0m\n",
              "        \u001b[33mid\u001b[0m=\u001b[32m'msg_67e38dbb1ea881929cddccf4767a45ec0c9277726feb508e'\u001b[0m,\n",
              "        \u001b[33mcontent\u001b[0m=\u001b[1m[\u001b[0m\n",
              "            \u001b[1;35mResponseOutputText\u001b[0m\u001b[1m(\u001b[0m\n",
              "                \u001b[33mannotations\u001b[0m=\u001b[1m[\u001b[0m\u001b[1m]\u001b[0m,\n",
              "                \u001b[33mtext\u001b[0m=\u001b[32m'Agentic AI refers to artificial intelligence systems that possess a degree of autonomy or \u001b[0m\n",
              "\u001b[32magency, allowing them to make decisions and take actions in dynamic environments without constant human oversight. \u001b[0m\n",
              "\u001b[32mThis type of AI is characterized by its ability to:\\n\\n1. **Interpret Context**: Understand and analyze situational\u001b[0m\n",
              "\u001b[32mcontexts to make informed decisions.\\n2. **Learn from Experience**: Adapt and improve performance over time through\u001b[0m\n",
              "\u001b[32mmachine learning techniques.\\n3. **Act Independently**: Carry out tasks or goals without needing specific \u001b[0m\n",
              "\u001b[32minstructions for every action.\\n4. **Exhibit Goal-Directed Behavior**: Operate with specific objectives in mind, \u001b[0m\n",
              "\u001b[32moften prioritizing efficiency and effectiveness.\\n\\nApplications of Agentic AI can be found across various domains,\u001b[0m\n",
              "\u001b[32msuch as autonomous vehicles, robotics, and sophisticated virtual assistants. However, its development raises \u001b[0m\n",
              "\u001b[32mimportant ethical and safety considerations, including accountability, transparency, and potential unintended \u001b[0m\n",
              "\u001b[32mconsequences.'\u001b[0m,\n",
              "                \u001b[33mtype\u001b[0m=\u001b[32m'output_text'\u001b[0m\n",
              "            \u001b[1m)\u001b[0m\n",
              "        \u001b[1m]\u001b[0m,\n",
              "        \u001b[33mrole\u001b[0m=\u001b[32m'assistant'\u001b[0m,\n",
              "        \u001b[33mstatus\u001b[0m=\u001b[32m'completed'\u001b[0m,\n",
              "        \u001b[33mtype\u001b[0m=\u001b[32m'message'\u001b[0m\n",
              "    \u001b[1m)\u001b[0m\n",
              "\u001b[1m]\u001b[0m\n"
            ],
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">[</span>\n",
              "    <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">ResponseOutputMessage</span><span style=\"font-weight: bold\">(</span>\n",
              "        <span style=\"color: #808000; text-decoration-color: #808000\">id</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'msg_67e38dbb1ea881929cddccf4767a45ec0c9277726feb508e'</span>,\n",
              "        <span style=\"color: #808000; text-decoration-color: #808000\">content</span>=<span style=\"font-weight: bold\">[</span>\n",
              "            <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">ResponseOutputText</span><span style=\"font-weight: bold\">(</span>\n",
              "                <span style=\"color: #808000; text-decoration-color: #808000\">annotations</span>=<span style=\"font-weight: bold\">[]</span>,\n",
              "                <span style=\"color: #808000; text-decoration-color: #808000\">text</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'Agentic AI refers to artificial intelligence systems that possess a degree of autonomy or </span>\n",
              "<span style=\"color: #008000; text-decoration-color: #008000\">agency, allowing them to make decisions and take actions in dynamic environments without constant human oversight. </span>\n",
              "<span style=\"color: #008000; text-decoration-color: #008000\">This type of AI is characterized by its ability to:\\n\\n1. **Interpret Context**: Understand and analyze situational</span>\n",
              "<span style=\"color: #008000; text-decoration-color: #008000\">contexts to make informed decisions.\\n2. **Learn from Experience**: Adapt and improve performance over time through</span>\n",
              "<span style=\"color: #008000; text-decoration-color: #008000\">machine learning techniques.\\n3. **Act Independently**: Carry out tasks or goals without needing specific </span>\n",
              "<span style=\"color: #008000; text-decoration-color: #008000\">instructions for every action.\\n4. **Exhibit Goal-Directed Behavior**: Operate with specific objectives in mind, </span>\n",
              "<span style=\"color: #008000; text-decoration-color: #008000\">often prioritizing efficiency and effectiveness.\\n\\nApplications of Agentic AI can be found across various domains,</span>\n",
              "<span style=\"color: #008000; text-decoration-color: #008000\">such as autonomous vehicles, robotics, and sophisticated virtual assistants. However, its development raises </span>\n",
              "<span style=\"color: #008000; text-decoration-color: #008000\">important ethical and safety considerations, including accountability, transparency, and potential unintended </span>\n",
              "<span style=\"color: #008000; text-decoration-color: #008000\">consequences.'</span>,\n",
              "                <span style=\"color: #808000; text-decoration-color: #808000\">type</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'output_text'</span>\n",
              "            <span style=\"font-weight: bold\">)</span>\n",
              "        <span style=\"font-weight: bold\">]</span>,\n",
              "        <span style=\"color: #808000; text-decoration-color: #808000\">role</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'assistant'</span>,\n",
              "        <span style=\"color: #808000; text-decoration-color: #808000\">status</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'completed'</span>,\n",
              "        <span style=\"color: #808000; text-decoration-color: #808000\">type</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'message'</span>\n",
              "    <span style=\"font-weight: bold\">)</span>\n",
              "<span style=\"font-weight: bold\">]</span>\n",
              "</pre>\n"
            ]
          },
          "metadata": {}
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "\u001b[1m[\u001b[0m\n",
              "    \u001b[1;35mWebSearchTool\u001b[0m\u001b[1m(\u001b[0m\n",
              "        \u001b[33mtype\u001b[0m=\u001b[32m'web_search_preview'\u001b[0m,\n",
              "        \u001b[33msearch_context_size\u001b[0m=\u001b[32m'medium'\u001b[0m,\n",
              "        \u001b[33muser_location\u001b[0m=\u001b[1;35mUserLocation\u001b[0m\u001b[1m(\u001b[0m\u001b[33mtype\u001b[0m=\u001b[32m'approximate'\u001b[0m, \u001b[33mcity\u001b[0m=\u001b[3;35mNone\u001b[0m, \u001b[33mcountry\u001b[0m=\u001b[32m'US'\u001b[0m, \u001b[33mregion\u001b[0m=\u001b[3;35mNone\u001b[0m, \u001b[33mtimezone\u001b[0m=\u001b[3;35mNone\u001b[0m\u001b[1m)\u001b[0m\n",
              "    \u001b[1m)\u001b[0m\n",
              "\u001b[1m]\u001b[0m\n"
            ],
            "text/html": [
              "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">[</span>\n",
              "    <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">WebSearchTool</span><span style=\"font-weight: bold\">(</span>\n",
              "        <span style=\"color: #808000; text-decoration-color: #808000\">type</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'web_search_preview'</span>,\n",
              "        <span style=\"color: #808000; text-decoration-color: #808000\">search_context_size</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'medium'</span>,\n",
              "        <span style=\"color: #808000; text-decoration-color: #808000\">user_location</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">UserLocation</span><span style=\"font-weight: bold\">(</span><span style=\"color: #808000; text-decoration-color: #808000\">type</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'approximate'</span>, <span style=\"color: #808000; text-decoration-color: #808000\">city</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>, <span style=\"color: #808000; text-decoration-color: #808000\">country</span>=<span style=\"color: #008000; text-decoration-color: #008000\">'US'</span>, <span style=\"color: #808000; text-decoration-color: #808000\">region</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span>, <span style=\"color: #808000; text-decoration-color: #808000\">timezone</span>=<span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span><span style=\"font-weight: bold\">)</span>\n",
              "    <span style=\"font-weight: bold\">)</span>\n",
              "<span style=\"font-weight: bold\">]</span>\n",
              "</pre>\n"
            ]
          },
          "metadata": {}
        }
      ]
    }
  ]
}